package com.sgb.jicai.view.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.widget.TextView;

import com.sgb.jicai.BR;
import com.sgb.jicai.R;
import com.swgk.core.base.model.entity.VideoBean;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class HomeHostVideoAdapter extends BaseRecycleAdapter<VideoBean> {

    private int type;

    public HomeHostVideoAdapter(Context context, List<VideoBean> datas, int layout, int type) {
        super(context, layout, datas);
        this.type = type;
    }

    @Override
    public void convert(ItemViewHolder holder, final VideoBean entity) {
        holder.setBinding(BR.viewModel, entity);
        TextView textView = holder.itemView.findViewById(R.id.tv_labelName);
        if (!TextUtils.isEmpty(entity.getTitle())){
            textView.setText(entity.getTitle());
        }else {
            textView.setText("");
        }
        String names = textView.getText().toString();
        if (!TextUtils.isEmpty(entity.getLabelName())){
            if (entity.getLabelName().length()>=7){
                textView.setText("# "+entity.getLabelName().substring(0,6)+"...\n"+names);
            }else {
                textView.setText("# "+entity.getLabelName()+" "+names);
            }
        }

    }
}
